<?php if(!defined('WANYA_ROOT')) {exit('error!');}?>
<div class=containertitle><b>课程-学生安排</b>
<?php if(isset($_GET['active_del'])):?><span class="actived">删除用户成功</span><?php endif;?>
</div>
<div class=line></div>
<form action="course_arrange.php" method="post" name="form_ca" id="form_ca">
	<fieldset style="border:2px solid #0099ff;">
		<legend>课程信息</legend>
		<table style="margin-bottom: 5px;margin-left: 10px">
			<tr>
				<td>课程：</td>
				<td>
					<input type="text" disabled="disabled" name="course_name" id="course_name" value="<?php echo($courseDetails["course_name"]);?>">　
					<input type="hidden" name="course_id" id="course_id" value="<?php echo($courseDetails["ID"]);?>" >
				</td>
				<td>批次：</td>
				<td>
					<input type="text" disabled="disabled" name="course_batch_show"  value="<?php echo($courseBatch==9999?"未产生":$courseBatch);?>">　
					<input type="hidden" name="course_batch" id="course_batch" value="<?php echo($courseBatch);?>">　
				</td>
			</tr>
		</table>
	</fieldset>
<br>
  <table width="55%" id="adm_comment_list" class="item_list">
	  <caption align="top">该批次已有学生</caption>
  	<thead>
      <tr>
	<th width="50" colspan="1"><b>选择</b></th>
        <th width="100" colspan="1"><b>姓名</b></th>
		<th width="300"><b>电话</b></th>
      </tr>
    </thead>
    <tbody>
	<?php
	if($alreadyStudents):
	foreach($alreadyStudents as $key=>$value):
	?>
     <tr>
		<td><input type="checkbox" value="<?php echo $value['ID']; ?>" name="alIds[]" class="alIds" /></td>
		<td><?php echo $value['name']; ?></td>
 		<td><?php echo $value['tel']; ?></td>

	<?php endforeach;else:?>
	  <tr><td class="tdcenter" colspan="4">还没有任何学生</td></tr>
	<?php endif;?>
	</tbody>
  </table>
	<div class="list_footer">
	<a href="javascript:void(0);" id="select_all_al">全选</a> 选中项：
    <a href="javascript:commitDelAl();" class="care">删除</a>
	</div>
    <div class="page">(共有<?php echo count($alreadyStudents); ?>个学生)</div>





	<table width="55%" id="adm_comment_list" class="item_list">
		<caption align="top">待安排学生</caption>
		<thead>
		<tr>
			<th width="50" colspan="1"><b>选择</b></th>
			<th width="100" colspan="1"><b>姓名</b></th>
			<th width="300"><b>电话</b></th>
		</tr>
		</thead>
		<tbody>
		<?php
		if($availableStudents):
			foreach($availableStudents as $key=>$value):
				?>
				<tr>
				<td><input type="checkbox" value="<?php echo $value['ID']; ?>" name="avIds[]" class="avIds" /></td>
				<td><?php echo $value['name']; ?></td>
				<td><?php echo $value['tel']; ?></td>

			<?php endforeach;else:?>
			<tr><td class="tdcenter" colspan="4">还没有任何学生</td></tr>
		<?php endif;?>
		</tbody>
	</table>
	<div class="list_footer">
		<a href="javascript:void(0);" id="select_all_av">全选</a> 选中项：
		<a href="javascript:commitDelAv();" class="care">删除</a>
		<a href="javascript:commitAdd();" class="care">添加到该批次</a>
		<input name="action" id="action" value="" type="hidden" />
	</div>
	<div class="page"> (共有<?php echo count($availableStudents); ?>个学生)</div>
</form>

<script>
$(document).ready(function(){
	$("#select_all_al").toggle(function () {$(".alIds").attr("checked", "checked");},function () {$(".alIds").removeAttr("checked");});
	$("#select_all_av").toggle(function () {$(".avIds").attr("checked", "checked");},function () {$(".avIds").removeAttr("checked");});
	$("#adm_comment_list tbody tr:odd").addClass("tralt_b");
	$("#adm_comment_list tbody tr")
		.mouseover(function(){$(this).addClass("trover");$(this).find("span").show();})
		.mouseout(function(){$(this).removeClass("trover");$(this).find("span").hide();})
});
setTimeout(hideActived,2600);
function commitDelAl(){
	if (getChecked('alIds') == false) {
		alert('请选择要删除的用户！');
		return;
	}
	if(!confirm("确认要删除所选学生的所在批次信息？"))
	{
		return;
	}
	$("#action").val("DelAl");
	$("#form_ca").submit();
}
function commitDelAv(){
	if (getChecked('avIds') == false) {
		alert('请选择要删除的用户!');
		return;
	}
	if(!confirm("确认要删除所选学生的报名信息？"))
	{
		return;
	}
	$("#action").val("DelAv");
	$("#form_ca").submit();
}
function commitAdd(){
	if (getChecked('avIds') == false) {
		alert('请选择要添加的用户');
		return;
	}
	$("#action").val("add");
	$("#form_ca").submit();
}
function course_arrange(courseID,courseBatch){
	window.location.href="course_arrange.php?courseID="+courseID+"&courseBatch="+courseBatch+"";
}

$("#menu_cm").addClass('sidebarsubmenu1');
</script>